using UnityEngine;
using XLua;
using Yoozoo.Mars.Got;

namespace Yoozoo.Gameplay.City
{
    public static class CityRealAiLuaCallCSharpManager
    {
        public static void OnInitialize()
        {
            CityRealAiManager.GetInstance().OnInitialize();
        }

        public static void CreateRoot(LuaTable table)
        {
            CityRealAiManager.GetInstance().CreateRoot(table);
        }

        public static void SetNpcMoveCtrObj(LuaTable table)
        {
            CityRealAiManager.GetInstance().SetNpcMoveCtrObj(table);
        }

        public static bool CheckAiCreateComplete()
        {
            return  CityRealAiManager.GetInstance().CheckAiCreateComplete();
        }
        public static void CreateAllRoomPoints(CityRealAiRoomDatas roomDatas)
        {
            CityRealAiManager.GetInstance().CreateAllRoomPoints(roomDatas);
        }

        public static void CreateRoomPoints(CityRealAiRoomData eventPointRoomConfig)
        {
            CityRealAiManager.GetInstance().CreateRoomPoints(eventPointRoomConfig);
        }

        public static void RemoveRoomPoints(LuaTable table)
        {
            CityRealAiManager.GetInstance().RemoveRoomPoints(table);
        }

        public static void CreateAllRoomNpc(LuaTable table)
        {
            CityRealAiManager.GetInstance().CreateAllRoomNpc(table);
        }

        public static void CreateRoomNpc(LuaTable table)
        {
            CityRealAiManager.GetInstance().CreateRoomNpc(table, true);
        }

        public static void CreateAllAreaNpc(LuaTable table)
        {
            CityRealAiManager.GetInstance().CreateAllAreaNpc(table);
        }

        public static void CreateAreaNpc(LuaTable table)
        {
            CityRealAiManager.GetInstance().CreateAreaNpc(table);
        }

        public static void RemoveStaffAreaNpc(LuaTable table)
        {
            CityRealAiManager.GetInstance().RemoveStaffNpcByStaffId(table);
        }

        public static void CreateUnlockAreaPerformNpc(LuaTable table)
        {
            CityRealAiManager.GetInstance().CreateUnlockAreaPerformNpc(table);
        }
        
        public static void CreateFrontEmployStaffNpc(LuaTable table)
        {
            CityRealAiManager.GetInstance().CreateFrontEmployStaffNpc(table);
        }

        public static void OnUnlockNpc(LuaTable table)
        {
            CityRealAiManager.GetInstance().OnUnlockNpc(table);
        }
        
        public static void CreateCastleHeroNpc(LuaTable table)
        {
            CityRealAiManager.GetInstance().CreateCastleHeroNpc(table);
        }

        public static void PlayNpcBreathEffect(int areaId, int buildId, int buildIndex, int cityRoleId, bool isShow)
        {
            CityRealAiManager.GetInstance().PlayNpcBreathEffect(areaId, buildId, buildIndex, cityRoleId, isShow);
        }

        public static CityRealAiNpcController GetNpcController(int areaId, int buildId, int buildIndex, int cityRoleId)
        {
            return CityRealAiManager.GetInstance().GetNpcController(areaId, buildId, buildIndex, cityRoleId);
        }
        
        public static void OnBusinessBuildingLevelUp(int buildingId, int buildingIndex)
        {
            CityRealAiManager.GetInstance().OnBusinessBuildingLevelUp(buildingId, buildingIndex);
        }

        public static void OpenBusiness(LuaTable table)
        {
            CityRealAiManager.GetInstance().OpenBusiness(table);
        }

        public static void CloseBusiness()
        {
            CityRealAiManager.GetInstance().CloseBusiness();
        }

        public static void RestoreOpenBusiness(LuaTable table)
        {
            CityRealAiManager.GetInstance().RestoreOpenBusiness(table);
        }

        public static float GetCustomerLeaveTime()
        {
            return CityRealAiConst.CustomerLeaveTime;
        }

        public static void ClearOpenBusiness()
        {
            CityRealAiManager.GetInstance().ClearOpenBusiness();
        }
        
        public static void OpenAutoBusiness(LuaTable table)
        {
            CityRealAiManager.GetInstance().OpenAutoBusiness(table);
        }
        
        public static void CloseAutoBusiness()
        {
            CityRealAiManager.GetInstance().CloseAutoBusiness();
        }

        public static void StopAllBabeMoodHud()
        {
            var roomMgr = CityRealAiManager.GetInstance().GetCityRealAiMansionLivingRoom();
            roomMgr.StopAllBabeMoodHud();
        }

        public static void RefreshAllBabeMoodHud()
        {
            var roomMgr = CityRealAiManager.GetInstance().GetCityRealAiMansionLivingRoom();
            roomMgr.RefreshAllBabeMoodHud();
        }
        
        public static GameObject GetBabeMoodHudById(int roleId)
        {
            var roomMgr = CityRealAiManager.GetInstance().GetCityRealAiMansionLivingRoom();
            return roomMgr.GetBabeMoodHudById(roleId);
        }
            
        public static Vector3 GetOccupyAreaBirthPoint(int areaId, int index)
        {
            // areaId、pointIndex从1开始
            var wallMgr = CityRealAiManager.GetInstance().GetCityRealAiWallManager();
            return wallMgr.GetOccupyAreaBirthPointWorldPos(areaId, index);
        }

        public static int GetFrontStaffHideEventTreeId()
        {
            return CityRealAiConst.FrontStaffHideEventTreeId;
        }
        
        public static int GetBackStaffHideEventTreeId()
        {
            return CityRealAiConst.BackStaffHideEventTreeId;
        }
        
        public static Vector3 GetFrontBirthPoint()
        {
            var wallMgr = CityRealAiManager.GetInstance().GetCityRealAiWallManager();
            return wallMgr.GetFrontBirthPointWorldPos();
        }

        public static Vector3 GetBackBirthPoint()
        {
            var wallMgr = CityRealAiManager.GetInstance().GetCityRealAiWallManager();
            return wallMgr.GetBackBirthPointWorldPos();
        }

        public static bool GetAreaStaffPosition(int staffId, out Vector3 position)
        {
            return CityRealAiManager.GetInstance().GetAreaStaffPosition(staffId, out position);
        }

        public static void TriggerHallSpecialEvent(int specialEvendId, int totalCount, int additionValue, bool killOtherBubble)
        {
            CityRealAiManager.GetInstance().TriggerHallSpecialEvent(specialEvendId, totalCount, additionValue, killOtherBubble);
        }

        public static void TriggerHallSpecialEventRecover()
        {
            CityRealAiManager.GetInstance().TriggerHallSpecialEventRecover();
        }

        public static void TryTriggerSpecialRecover(int uid, int specialId)
        {
            CityRealAiManager.GetInstance().TryTriggerSpecialRecover(uid, specialId);
        }

        public static void SwitchInnerCityDailyStage(float timeSpeed, float startProgress)
        {
            InnerCityBluprintUtils.SwitchInnerCityDailyStage(timeSpeed, startProgress, null);
        }

        public static void TransferDayNight(float timeSpeed, float toProgress)
        {
            int repeat = 20;
            var setSunOrRainInstance = SetSunorRain.getInstance();
            float speed = (toProgress - setSunOrRainInstance.RainSpeedV) / repeat;

            Timers.inst.Add(0.05f, repeat, (param) =>
            {
                float value = Mathf.Clamp01(setSunOrRainInstance.RainSpeedV + speed);
                InnerCityBluprintUtils.SwitchInnerCityDailyStage(timeSpeed, value, null);
            });
        }

        /// <summary>
        /// 设置dj自动涨钱时长
        /// </summary>
        /// <param name="duration"></param>
        public static void SetAutoDJDuration(float duration)
        {
            CityRealAiConst.AutoDJDuration = duration;
        }

        /// <summary>
        /// 设置当前是否可以显示商品气泡
        /// </summary>
        /// <param name="canShowCommodityBubble"></param>
        public static void SetCanShowCommodityBubble(bool canShowCommodityBubble)
        {
            CityRealAiConst.CanShowCommodityBubble = canShowCommodityBubble;
        }
        
        /// <summary>
        /// 设置当前是否允许显示自动消费进度条
        /// </summary>
        /// <param name="canShowAutoCustomProgressBar"></param>
        public static void SetCanShowAutoCustomProgressBar(bool canShowAutoCustomProgressBar)
        {
            CityRealAiConst.CanShowAutoCustomProgressBar = canShowAutoCustomProgressBar;
        }
        
        /// <summary>
        /// 设置当前气泡触发概率
        /// </summary>
        /// <param name="probability"></param>
        public static void SetCommodityBubbleProbability(int probability)
        {
            CityRealAiConst.CommodityBubbleProbability = probability;
        }

        /// <summary>
        /// 设置商品气泡触发限制CD
        /// </summary>
        /// <param name="cd"></param>
        public static void SetCommodityPerlimitCD(float cd)
        {
            CityRealAiManager.GetInstance().SetCommodityPerlimitCD(cd);
        }

        /// <summary>
        /// 设置商品气泡触发限制数量
        /// </summary>
        /// <param name="maxCount"></param>
        public static void SetCommodityPerlimitMaxCount(int maxCount)
        {
            CityRealAiManager.GetInstance().SetCommodityPerlimitMaxCount(maxCount);
        }

        public static void SetCommodityPerlimitTimerAndCount(float timer, int count)
        {
            CityRealAiManager.GetInstance().SetCommodityPerlimitTimerAndCount(timer, count);
        }

        /// <summary>
        /// 隐藏商品气泡
        /// </summary>
        /// <param name="uid"></param>
        public static void HideCommodityBubble(int uid)
        {
            CityRealAiManager.GetInstance().HudMgr.OnHideCommodity(uid);
        }
        
        /// <summary>
        /// 延迟隐藏商品气泡
        /// </summary>
        /// <param name="uid"></param>
        /// <param name="delayTime"></param>
        public static void PlayProgressAndHideCommodityBubble(int uid, float duration)
        {
            CityRealAiManager.GetInstance().HudMgr.PlayProgressAndHideCommodityBubble(uid, duration);
        }

        /// <summary>
        /// 删除垃圾，以及气泡
        /// </summary>
        /// <param name="areaId"></param>
        /// <param name="buildId"></param>
        /// <param name="buildIndex"></param>
        /// <param name="uid"></param>
        public static void HideRubbish(int areaId, int buildId, int buildIndex, int uid, float duration)
        {
            CityRealAiManager.GetInstance().HideRubbish(areaId, buildId, buildIndex, uid, duration);
        }

        /// <summary>
        /// 删除毁坏设施，以及气泡
        /// </summary>
        /// <param name="areaId"></param>
        /// <param name="buildId"></param>
        /// <param name="buildIndex"></param>
        /// <param name="uid"></param>
        public static void HideFix(int areaId, int buildId, int buildIndex, int uid, float duration)
        {
            CityRealAiManager.GetInstance().HideFix(areaId, buildId, buildIndex, uid, duration);
        }

        /// <summary>
        /// 显示商品消费气泡
        /// </summary>
        /// <param name="uid"></param>
        /// <param name="roleTran"></param>
        /// <param name="displayTime"></param>
        /// <param name="stringParam"></param>
        public static void ShowCommodityCostBubble(int uid, Transform roleTran, float displayTime, string stringParam)
        {
            CityRealAiManager.GetInstance().HudMgr.OnShowHud(uid, roleTran, CityRealAiConst.CommodityCostBubble, displayTime, CityRealAiConst.DefaultBubbleBone
                , 0, stringParam);
        }
        
        /// <summary>
        /// 显示点赞气泡
        /// </summary>
        /// <param name="uid"></param>
        /// <param name="roleTran"></param>
        /// <param name="displayTime"></param>
        /// <param name="stringParam"></param>
        public static void ShowCommodityLikeBubble(int uid, Transform roleTran, float displayTime, string stringParam)
        {
            CityRealAiManager.GetInstance().HudMgr.OnShowHud(uid, roleTran, CityRealAiConst.CommodityLikeBubble, displayTime, CityRealAiConst.DefaultBubbleBone
                , 0, stringParam);
        }
        
        /// <summary>
        /// 显示雇员气泡
        /// </summary>
        /// <param name="uid"></param>
        /// <param name="roleTran"></param>
        /// <param name="displayTime"></param>
        /// <param name="stringParam"></param>
        public static void ShowStaffBubble(int uid, Transform roleTran, float displayTime, string stringParam)
        {
            CityRealAiManager.GetInstance().HudMgr.OnShowHud(uid, roleTran, CityRealAiConst.StaffBubble, displayTime, CityRealAiConst.DefaultBubbleBone
                , 0, stringParam);
        }

        /// <summary>
        /// 显示开心特效
        /// </summary>
        public static void ShowHappyEffectBubble(int uid, Transform roleTran)
        {
            CityRealAiManager.GetInstance().HudMgr.OnShowEffect(uid, roleTran, CityRealAiConst.CustomerHappyEffect, CityRealAiConst.CustomerMoodEffectDuration, CityRealAiConst.DefaultBubbleBone);
        }
        
        /// <summary>
        /// 显示伤心特效
        /// </summary>
        public static void ShowSadEffectBubble(int uid, Transform roleTran)
        {
            CityRealAiManager.GetInstance().HudMgr.OnShowEffect(uid, roleTran, CityRealAiConst.CustomerSadEffect, CityRealAiConst.CustomerMoodEffectDuration, CityRealAiConst.DefaultBubbleBone);
        }
        

        /// <summary>
        /// 检票时长
        /// </summary>
        /// <param name="time"></param>
        public static void SetCheckTicketTime(float time)
        {
            CityRealAiConst.CheckTicketTime = time;
        }

        /// <summary>
        /// 房间接待单个客人需要的时长
        /// </summary>
        /// <param name="time"></param>
        public static void SetRoomReceptionTime(int buildingId, float time)
        {
            CityRealAiManager.GetInstance().ConfigMgr.SetRoomReceptionTime(buildingId, time);
        }
        
        public static void StartSpecialStateTimer()
        {
            CityRealAiManager.GetInstance().StartSpecialStateTimer();
        }

        public static void OnReStartCity()
        {
            CityRealAiManager.GetInstance().OnReStartCity();
        }

        public static void OnStopCity()
        {
            CityRealAiManager.GetInstance().OnStopCity();
        }

        public static void OnExitCity()
        {
            CityRealAiManager.GetInstance().OnExitCity();
        }

        public static void OnDispose()
        {
            CityRealAiManager.GetInstance().Dispose();
        }
        
        public static void OnReStartRoomAllNpc(LuaTable table)
        {
            CityRealAiManager.GetInstance().OnReStartRoomAllNpc(table);
        }

        public static void OnStopRoomAllNpc(LuaTable table)
        {
            CityRealAiManager.GetInstance().OnStopRoomAllNpc(table);
        }

        public static void LoadChangeShowOrHideAllNpc(LuaTable table)
        {
            CityRealAiManager.GetInstance().LoadChangeShowOrHideAllNpc(table);
        }

        public static void OnLodChangeShowOrHideRoomAllNpc(LuaTable table)
        {
            CityRealAiManager.GetInstance().OnLodChangeShowOrHideRoomAllNpc(table);
        }

        public static void SetupEventPointRoomConfig(CityRealAiEventPointRoomConfigs eventPointRoomConfigs)
        {
            CityRealAiManager.GetInstance().ConfigMgr.SetupEventPointRoomConfig(ref eventPointRoomConfigs);
        }

        public static void SetupRoomEventConfig(CityRealAiRoomEventConfigs roomEventConfigs)
        {
            CityRealAiManager.GetInstance().ConfigMgr.SetupRoomEventConfig(ref roomEventConfigs);
        }

        public static void SetupRoleInfoConfig(CityRealAiRoleInfoConfigs roleInfoConfigs)
        {
            CityRealAiManager.GetInstance().ConfigMgr.SetupRoleInfoConfig(ref roleInfoConfigs);
        }

        public static void SetupRoomBehaviorConfig(CityRealAiRoomBehaviorConfigs behaviorConfigs)
        {
            CityRealAiManager.GetInstance().ConfigMgr.SetupRoomBehaviorConfig(ref behaviorConfigs);
        }

        public static void SetupRoleConfig(CityRealAiRoleConfigs roleConfigs)
        {
            CityRealAiManager.GetInstance().ConfigMgr.SetupRoleConfig(ref roleConfigs);
        }

        public static void SetupEventTreeConfig(CityRealAiEventTreeConfigs eventTreeConfigs)
        {
            CityRealAiManager.GetInstance().ConfigMgr.SetupEventTreeConfig(ref eventTreeConfigs);
        }

        public static void SetupEventConfig(CityRealAiEventConfigs eventConfigs)
        {
            CityRealAiManager.GetInstance().ConfigMgr.SetupEventConfig(ref eventConfigs);
        }

        public static void SetupBonePathConfig(CityRealAiNPCBonePathConfigs bonePathConfigs)
        {
            CityRealAiManager.GetInstance().ConfigMgr.SetupBonePathConfig(ref bonePathConfigs);
        }

        public static void SetupQueueMoodConfig(CityRealAiNPCQueueMoodConfigs queueMoodConfigs)
        {
            CityRealAiManager.GetInstance().ConfigMgr.SetupQueueMoodConfig(ref queueMoodConfigs);
        }

        public static void SetupOperateInteractiveConfig(CityRealAiOperateInteractiveConfigs operateInteractiveConfigs)
        {
            CityRealAiManager.GetInstance().ConfigMgr.SetupOperateInteractiveConfig(ref operateInteractiveConfigs);
        }

        public static void SetupSpecialConfigs(CityRealAiSpecialConfigs specialConfigs)
        {
            CityRealAiManager.GetInstance().ConfigMgr.SetupSpecialConfigs(ref specialConfigs);
        }

        public static void SetupSpecialRecoverConfigs(CityRealAiSpecialRecoverConfigs specialRecoverConfigs)
        {
            CityRealAiManager.GetInstance().ConfigMgr.SetupSpecialRecoverConfigs(ref specialRecoverConfigs);
        }

        public static void SetupGlobalVariablesConfig(GlobalVariablesConfig globalConfig)
        {
            CityRealAiManager.GetInstance().ConfigMgr.SetupGlobalVariablesConfig(ref globalConfig);
        }
        
        public static void OnAddQueue(LuaTable table)
        {
            CityRealAiManager.GetInstance().OnAddQueue(table);
        }

        public static void OnRemoveQueue(LuaTable table)
        {
            CityRealAiManager.GetInstance().OnRemoveQueue(table);
        }
        
        public static void OnWoundedSoldierChanged(LuaTable table)
        {
            CityRealAiManager.GetInstance().OnWoundedSoldierChanged(table);
        }

        public static void OnAssemblyChanged(LuaTable table)
        {
            CityRealAiManager.GetInstance().OnAssemblyChanged(table);
        }

        public static void OnReinforceChanged(LuaTable table)
        {
            CityRealAiManager.GetInstance().OnReinforceChanged(table);
        }

        public static void OnUnlockBus(LuaTable table)
        {
            CityRealAiManager.GetInstance().OnUnlockBus(table);
        }

        public static GameObject GetAreaStaffHudById(int staffId)
        {
            return CityRealAiManager.GetInstance().GetAreaStaffHUDById(staffId);
        }

        public static void RefreshAreaStaffHud(LuaTable table)
        {
            CityRealAiManager.GetInstance().RefreshAreaStaffHud(table);
        }

        public static void SetAreaStaffHudCollider(bool state)
        {
            CityRealAiManager.GetInstance().SetAreaStaffHudCollider(state);
        }
        

        public static void TimelineJumpEvent()
        {
            CityRealAiManager.GetInstance().TimelineJumpEvent();
        }
    }
}
